package com.chey.controller;

import com.chey.domain.Area;
import com.chey.domain.Day;
import com.chey.domain.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author JanYao
 * @version 0.1
 */
@RestController
public class EchartsController {

    @Autowired
    private com.chey.service.EchartsService echartsService;

    @GetMapping("/statistics/area")
    public ResponseData getEchartsAreaData(){
        Area echartsAreaData = echartsService.getEchartsAreaData();
        ResponseData data = new ResponseData();
        data.setCode(200);
        data.setData(echartsAreaData);
        System.out.println(echartsAreaData);
        return data;
    }
    @GetMapping("/statistics/ad")
    public ResponseData getEchartsADData(){
        Map<String, List<Day>> echartsADData = echartsService.getEchartsADData();
        ResponseData data = new ResponseData();
        data.setCode(200);
        data.setData(echartsADData);
        return data;
    }


    @GetMapping("/statistics/exception")
    public ResponseData getExceptionCounts(){
        Map<String, Integer> counts = echartsService.getExceptionCounts();
        ResponseData data = new ResponseData();
        data.setCode(200);
       data.setData(counts);
        return data;
    }

}
